<?php  
/* 
Template Name: Page Video
*/
?><?php get_header();?>
<div class="cy-content">
	<?php get_sidebar();?>
    <div class="cy-content-center">
    <?php locate_template('block/block-search.php', true); ?>
    <div class="cy-content-title">
    <h2><?php the_title();?></h2>
    </div><!--cy-content-title-->
        <?php
		wp_reset_query();
		//query the post 
		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;	
		//query_posts('meta_key=_mf_write_panel_id&meta_value=1&');
		?> 
        <ul class="cy-video-item">
        <?php 	
	  	$loop = new WP_Query(array('post_type'=>'thu_vien_video', 'posts_per_page' =>12,'paged' =>$paged));
	   ?>        
	    <?php while ( $loop->have_posts() ) : $loop->the_post(); //bat dau vong lap ?>
        
        <li>
        <h3><?php the_title();?></h3>
     	<p>
            <iframe width="200" height="200" src="http://www.youtube.com/embed/<?php echo get('file');?>" frameborder="0" allowfullscreen> </iframe>
        </p>
        </li>
        <?php endwhile; //ket thuc vong lap ?>
        <?php wp_reset_query();?>  
        </ul><!---cy-video-item--->
        <center>
        <div class="cy-pagination">
        <?php // OK, custom tax's dont work nice with query_posts (i think) but they DEF dont work nice with next_posts(), previous_posts() and  posts_nav_link()
              // SO, got the custom page nav from here:
              // http://wordpress.org/support/topic/adding-pagination-to-a-wp_query-loop?replies=16
        if($loop->max_num_pages>1){
          if ($paged > 1) { ?>
            <a href="<?php echo '?category_product='.$p.'&paged=' . ($paged -1); //prev link ?>">«</a>
          <?php
          }
          for($i=1;$i<=$loop->max_num_pages;$i++){?>
          	<?php if($i==$paged){?>
            <span><?php echo $i;?></span>
			<?php } else {?>
            <a href="<?php echo '?category_product='.$p.'&paged=' . $i; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a>
          <?php
			}//end if
          } //end for
          if($paged < $loop->max_num_pages){?>
            <a href="<?php echo '?category_product='.$p.'&paged=' . ($paged + 1); //next link ?>">»</a>
          <?php
          }
        }?>
        </div><!--cy-pagination-->
		</center>
    </div><!--cy-content-center-->  
</div><!--cy-content-->
<?php get_footer(); ?>